package cn.robot.board;

import android.app.Application;
import android.database.sqlite.SQLiteDatabase;

import cn.robot.board.greendao.trails.db.DaoMaster;
import cn.robot.board.greendao.trails.db.DaoSession;

/**
 * Created by robot
 */

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        initGreenDao();
    }

    public static DaoSession daoSession;

    @Override
    public void onTerminate() {
        // 程序终止的时候执行
        super.onTerminate();
    }

    private void initGreenDao() {
        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "trails.db");
        SQLiteDatabase db = helper.getWritableDatabase();
        DaoMaster daoMaster = new DaoMaster(db);
        daoSession = daoMaster.newSession();
    }
}
